<?php

class Administration_MainController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
    }

    public function indexAction() {
        $servicesForm = new Administration_Form_Services();
        $this->view->servicesForm = $servicesForm;
        if ($this->getRequest()->isPost()) {
            if ($this->getRequest()->getParam("id") == "service") {
                if ($servicesForm->isValid($this->getRequest()->getParams())) {
                    $serviceModel = new Administration_Model_Service();
                    $numbers = ['One','Two','Three'];
                    for ($i = 0 ; $i < 3; $i++){
                    $serviceTitle = $servicesForm->getValue("serviceTitle".$numbers[$i]);
                    $serviceBody = $servicesForm->getValue("serviceBody".$numbers[$i]);
                    $serviceImage = $servicesForm->getValue("serviceImage".$numbers[$i]);
                    $readMoreLink = $servicesForm->getValue("readMoreLink".$numbers[$i]);
                    
                    //insert service
                    $serviceModel->addSerive($numbers[$i], $serviceTitle, $serviceBody, $serviceImage, $readMore);
                    }
                } else {
                    $this->view->errors = $servicesForm->getMessages();
                }
            }
        }
    }

}
